<?php
namespace Home\Controller;
use Think\Controller;
class UserController extends Controller {
	protected $userId;
	
	protected function isAuthorize(){
    $loginStatus=session('loginStatus');
    if(!$loginStatus){
       $this->redirect('User/userLogin','',2,'not authirize');
       exit();
     }
    $this->userId=session('id');
    $userName=session('email');
    $this->assign('userName',$userName);
    $this->assign('userId',$this->userId);	

   }

   
    public function modifyPhone(){
   	$this->isAuthorize();
   	$userObj= new \Home\Model\UserModel();
   	if(empty($_POST)){
   		$numberPhone= $userObj->getPhoneNumber($this->userId);
   		$this->assign('numberPhone',$numberPhone);
   		$this->display('Phone');
   		return false;
   	}
   
   	$status=$userObj->userModifyPhone($this->userId,$data);
   	if($status !==false){
   	$this->redirect('manager/index','',2,'update ok');
   	}else{
   	  echo $userObj->lastErrorMessage;
   	}
   }
   
   public function modifyPassword(){
   $this->isAuthorize();
   $userObj= new \Home\Model\UserModel();
   if(empty($_POST)){
   	$this->display('password');
   	return false;
   }
   $status=$userObj->userModifyPassword($this->userId,$_POST);
   if($status !==false){
	   $this->redirect('manager/index','',2,'update ok');
    }else{
	   echo $userObj->lastErrorMessage;
    }

   }
}